package states.gameplay.shapors;

import com.corvo.pulsor.Assets;

import resources.ResourceManager;

public class ShaporFactory {

	public static enum Type {BASE, EXPANDOR, ENERGOR, STORAGOR, WALLOR, CREEP_GENERATOR, ENEMY_CREEP, LIGHT_DEFENDER, MEDIUM_DEFENDER, HEAVY_DEFENDER};
	
	private ResourceManager _rm;
	
	public ShaporFactory(ResourceManager rm){
		_rm = rm;
	}
	
	public int getCost(final Type shaporType){
		int result = 0;
		switch(shaporType){
		case EXPANDOR:
			result = 10;
			break;
		case ENERGOR:
			result = 20;
			break;
		case STORAGOR:
			result = 20;
			break;
		case WALLOR:
			result = 20;
			break;
		case LIGHT_DEFENDER:
			result = 10;
			break;
		case MEDIUM_DEFENDER:
			result = 20;
			break;
		case HEAVY_DEFENDER:
			result = 30;
			break;
		default:
			break;
		}
		
		return result;
	}
	
	public int getDeployCicles(final Type shaporType){
		int result = 0;
		switch(shaporType){
		case EXPANDOR:
			result = 2;
			break;
		case ENERGOR:
			result = 3;
			break;
		case STORAGOR:
			result = 2;
			break;
		case WALLOR:
			result = 2;
			break;
		case LIGHT_DEFENDER:
			result = 1;
			break;
		case MEDIUM_DEFENDER:
			result = 2;
			break;
		case HEAVY_DEFENDER:
			result = 3;
			break;
		default:
			break;
		}
		
		return result;
	}
	
	public int getDeployLimits(final Type shaporType){
		int result = 0;
		switch(shaporType){
		case BASE:
			result = 4;
			break;
		case EXPANDOR:
			result = 4;
			break;
		case ENERGOR:
			result = 1;
			break;
		case STORAGOR:
			result = 1;
		case WALLOR:
			result = 1;
			break;
		case LIGHT_DEFENDER:
			result = 1;
			break;
		case MEDIUM_DEFENDER:
			result = 1;
			break;
		case HEAVY_DEFENDER:
			result = 1;
			break;
		default:
			break;
		}
		
		return result;
	}
	
	public int getEnergyUpkeep(final Type shaporType){
		int result = 0;
		switch(shaporType){
		case BASE:
			result = 0;
			break;
		case EXPANDOR:
			result = 1;
			break;
		case ENERGOR:
			result = 0;
			break;
		case STORAGOR:
			result = 1;
			break;
		case WALLOR:
			result = 3;
			break;
		case LIGHT_DEFENDER:
			result = 1;
			break;
		case MEDIUM_DEFENDER:
			result = 1;
			break;
		case HEAVY_DEFENDER:
			result = 2;
			break;
		default:
			break;
		}
		
		return result;
	}
	
	public int getAttackRadius(final Type shaporType){
		int result = 0;
		switch(shaporType){
		case LIGHT_DEFENDER:
			result = 2;
			break;
		case MEDIUM_DEFENDER:
			result = 3;
			break;
		case HEAVY_DEFENDER:
			result = 4;
			break;
		default:
			break;
		}
		
		return result;
	}
	
	public EnemyCreep getEnemyCreep(){
		return new EnemyCreep(_rm.getImage( Assets.CREEP_ENEMY.getId() ));
	}
	
	public EnemyCreepGenerator getEnemyCreepGenerator(){
		return new EnemyCreepGenerator(_rm.getImage( Assets.ACTOR_CREEP_GENERATOR.getId() ));
	}
	
	public Base generateBase(){
		return new Base(3, 1, _rm.getImage(Assets.ACTOR_BASE.getId()), getCost(Type.BASE), 5);
	}
	
	public Expandor generateExpandor(){
		return new Expandor(getDeployLimits(Type.EXPANDOR), 
							_rm.getImage(Assets.ACTOR_EXPANDOR.getId()), 
							getCost(Type.EXPANDOR), 
							getDeployCicles(Type.EXPANDOR),
							getEnergyUpkeep(Type.EXPANDOR));
	}
	
	public Energor generateEnergor(){
		return new Energor(getDeployLimits(Type.ENERGOR),  // deploy limits
						   getCost(Type.ENERGOR), 		   // deploy costs
						   getDeployCicles(Type.ENERGOR),  // deploy pulses
						   3, 							   //energy generation
						   _rm.getImage(Assets.ACTOR_ENERGOR.getId()));
	}
	
	public Storagor generateStoragor(){
		return new Storagor(getDeployLimits(Type.STORAGOR), 
						   getCost(Type.STORAGOR), 
						   getDeployCicles(Type.STORAGOR),
						   getEnergyUpkeep(Type.STORAGOR), 
						   5, // capcity
						   _rm.getImage(Assets.ACTOR_STORAGOR.getId()));
	}

	public LasorDefender generateLightDefender() {
		return new LasorDefender(getDeployLimits(Type.LIGHT_DEFENDER), 
								 getCost(Type.LIGHT_DEFENDER), 
								 getDeployCicles(Type.LIGHT_DEFENDER), 
								 getEnergyUpkeep(Type.LIGHT_DEFENDER),
								 getAttackRadius(Type.LIGHT_DEFENDER),
								 _rm.getImage(Assets.ACTOR_LIGHT_DEFENDER.getId()));
	}
	
	public GranadorDefender generateMediumDefender() {
		return new GranadorDefender(getDeployLimits(Type.MEDIUM_DEFENDER), 
								 getCost(Type.MEDIUM_DEFENDER), 
								 getDeployCicles(Type.MEDIUM_DEFENDER), 
								 getEnergyUpkeep(Type.MEDIUM_DEFENDER),
								 getAttackRadius(Type.MEDIUM_DEFENDER),
								 _rm.getImage(Assets.ACTOR_MEDIUM_DEFENDER.getId()));
	}
	
	public HeavyDefender generateHeavyDefender() {
		return new HeavyDefender(getDeployLimits(Type.HEAVY_DEFENDER), 
								 getCost(Type.HEAVY_DEFENDER), 
								 getDeployCicles(Type.HEAVY_DEFENDER), 
								 getEnergyUpkeep(Type.HEAVY_DEFENDER),
								 getAttackRadius(Type.HEAVY_DEFENDER),
								 _rm.getImage(Assets.ACTOR_HEAVY_DEFENDER.getId()));
	}

	public Wallor generateWallor() {
		return new Wallor(getDeployLimits(Type.WALLOR), 
						  getCost(Type.WALLOR), 
						  getDeployCicles(Type.WALLOR),
						  getEnergyUpkeep(Type.WALLOR),
						  5,
						  2,
						  _rm.getImage(Assets.ACTOR_WALLOR.getId()) );
	}
}
